package com.smart.controller.app;

import java.util.List;
import com.smart.vo.SsWorkVo;
import com.smart.entity.SsWork;
import javax.annotation.Resource;
import io.swagger.annotations.Api;
import com.smart.service.SsWorkService;
import com.smart.common.util.Messages;
import com.smart.controller.BaseController;
import io.swagger.annotations.ApiOperation;
import javax.servlet.http.HttpServletRequest;
import com.baomidou.mybatisplus.extension.api.R;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author lgb
 * @date 2020年6月13日 上午10:53:34
 * Copyright (C) 深圳工勘科技
 * @说明: 智慧工地-作业记录表
 **/
@RestController
@RequestMapping("/app/sswork")
@Api(value="sswork",tags="智慧工地-作业记录表管理")
public class SsWorkController extends BaseController{

	@Resource
    private SsWorkService ssWorkService;

    /**
     * 分页查询
     * @param page   分页对象
     * @param appSsWork 智慧工地-作业记录表
     * @return
     **/
	@ApiOperation(value="分页查询", notes="分页查询")
    @GetMapping("/page")
    public Messages<List<SsWork>> getSsWorkPage(String createTime,
    		@RequestParam(name="pageNum")Integer pageNum,
			@RequestParam(name="pageSize")Integer pageSize,SsWork appSsWork,
    		HttpServletRequest request) {
        //获取当前用户信息
    	List<SsWork> page = ssWorkService.findPage(createTime, pageNum, pageSize);
        return Messages.success(page);
    }


    /**
     * 通过id查询智慧工地-作业记录表
     * @param id id
     * @return R
     **/
    @ApiOperation(value = "通过id查询", notes = "通过id查询")
    @GetMapping("/{id}")
    public R<SsWork> getById(@PathVariable("id")Long id) {
        return R.ok(ssWorkService.findById(id));
    }

    /**
     * 新增智慧工地-作业记录表
     * @param dto 智慧工地-作业记录表
     * @return R
     **/
    @PostMapping
    @ApiOperation(value="新增智慧工地-作业记录表",notes="新增智慧工地-作业记录表")
    public Messages<String> save(@RequestBody SsWorkVo dto) {
        return Messages.success(ssWorkService.saveSsWork(dto));
    }

    /**
     * 修改智慧工地-作业记录表
     * @param appSsWork 智慧工地-作业记录表
     * @return R
     **/
    @PutMapping
    @ApiOperation(value="修改智慧工地-作业记录表",notes="修改智慧工地-作业记录表")
    public R<Boolean> updateById(@RequestBody SsWork ssWork) {
        return R.ok(ssWorkService.updateEntity(ssWork));
    }

    /**
     * 通过id删除智慧工地-作业记录表
     * @param id id
     * @return R
     **/
    @ApiOperation(value="通过id删除智慧工地-作业记录表",notes="通过id删除智慧工地-作业记录表")
    @DeleteMapping("/{id}")
    public R<Boolean> removeById(@PathVariable Long id) {
        return R.ok(ssWorkService.deleteById(id));
    }

}